#pragma once
// MESSAGE Magnetometer PACKING

#define MAVLINK_MSG_ID_Magnetometer 151

MAVPACKED(
typedef struct __mavlink_magnetometer_t {
 uint32_t ma; /*< [null] magnetometer X axis chip original data.*/
 uint32_t malvX; /*< [null] magnetometer X axis filtered data.*/
 uint32_t mastartY; /*< [null] magnetometer Y axis chip original data.*/
 uint32_t malvY; /*< [null] magnetometer Y axis filtered data.*/
 uint32_t maAngle; /*< [degree] magnetometer get angles data.*/
 uint32_t maNumber; /*< [num] magnetometer offset sample data number.*/
 uint32_t malingX; /*< [null] magnetometer X axis offset data.*/
 uint32_t malingY; /*< [null] magnetometer Y axis offset data.*/
 uint32_t mascircle; /*< [rate] magnetometer circle define rate data.*/
 uint32_t gyP; /*< [null] magnetometer Kalman filter P param.*/
 uint32_t gyQ; /*< [null] magnetometer Kalman filter Q param.*/
 uint32_t gyR; /*< [null] magnetometer Kalman filter R param.*/
}) mavlink_magnetometer_t;

#define MAVLINK_MSG_ID_Magnetometer_LEN 48
#define MAVLINK_MSG_ID_Magnetometer_MIN_LEN 48
#define MAVLINK_MSG_ID_151_LEN 48
#define MAVLINK_MSG_ID_151_MIN_LEN 48

#define MAVLINK_MSG_ID_Magnetometer_CRC 162
#define MAVLINK_MSG_ID_151_CRC 162



#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_Magnetometer { \
    151, \
    "Magnetometer", \
    12, \
    {  { "ma", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_magnetometer_t, ma) }, \
         { "malvX", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_magnetometer_t, malvX) }, \
         { "mastartY", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_magnetometer_t, mastartY) }, \
         { "malvY", NULL, MAVLINK_TYPE_UINT32_T, 0, 12, offsetof(mavlink_magnetometer_t, malvY) }, \
         { "maAngle", NULL, MAVLINK_TYPE_UINT32_T, 0, 16, offsetof(mavlink_magnetometer_t, maAngle) }, \
         { "maNumber", NULL, MAVLINK_TYPE_UINT32_T, 0, 20, offsetof(mavlink_magnetometer_t, maNumber) }, \
         { "malingX", NULL, MAVLINK_TYPE_UINT32_T, 0, 24, offsetof(mavlink_magnetometer_t, malingX) }, \
         { "malingY", NULL, MAVLINK_TYPE_UINT32_T, 0, 28, offsetof(mavlink_magnetometer_t, malingY) }, \
         { "mascircle", NULL, MAVLINK_TYPE_UINT32_T, 0, 32, offsetof(mavlink_magnetometer_t, mascircle) }, \
         { "gyP", NULL, MAVLINK_TYPE_UINT32_T, 0, 36, offsetof(mavlink_magnetometer_t, gyP) }, \
         { "gyQ", NULL, MAVLINK_TYPE_UINT32_T, 0, 40, offsetof(mavlink_magnetometer_t, gyQ) }, \
         { "gyR", NULL, MAVLINK_TYPE_UINT32_T, 0, 44, offsetof(mavlink_magnetometer_t, gyR) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_Magnetometer { \
    "Magnetometer", \
    12, \
    {  { "ma", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_magnetometer_t, ma) }, \
         { "malvX", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_magnetometer_t, malvX) }, \
         { "mastartY", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_magnetometer_t, mastartY) }, \
         { "malvY", NULL, MAVLINK_TYPE_UINT32_T, 0, 12, offsetof(mavlink_magnetometer_t, malvY) }, \
         { "maAngle", NULL, MAVLINK_TYPE_UINT32_T, 0, 16, offsetof(mavlink_magnetometer_t, maAngle) }, \
         { "maNumber", NULL, MAVLINK_TYPE_UINT32_T, 0, 20, offsetof(mavlink_magnetometer_t, maNumber) }, \
         { "malingX", NULL, MAVLINK_TYPE_UINT32_T, 0, 24, offsetof(mavlink_magnetometer_t, malingX) }, \
         { "malingY", NULL, MAVLINK_TYPE_UINT32_T, 0, 28, offsetof(mavlink_magnetometer_t, malingY) }, \
         { "mascircle", NULL, MAVLINK_TYPE_UINT32_T, 0, 32, offsetof(mavlink_magnetometer_t, mascircle) }, \
         { "gyP", NULL, MAVLINK_TYPE_UINT32_T, 0, 36, offsetof(mavlink_magnetometer_t, gyP) }, \
         { "gyQ", NULL, MAVLINK_TYPE_UINT32_T, 0, 40, offsetof(mavlink_magnetometer_t, gyQ) }, \
         { "gyR", NULL, MAVLINK_TYPE_UINT32_T, 0, 44, offsetof(mavlink_magnetometer_t, gyR) }, \
         } \
}
#endif

/**
 * @brief Pack a magnetometer message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param ma [null] magnetometer X axis chip original data.
 * @param malvX [null] magnetometer X axis filtered data.
 * @param mastartY [null] magnetometer Y axis chip original data.
 * @param malvY [null] magnetometer Y axis filtered data.
 * @param maAngle [degree] magnetometer get angles data.
 * @param maNumber [num] magnetometer offset sample data number.
 * @param malingX [null] magnetometer X axis offset data.
 * @param malingY [null] magnetometer Y axis offset data.
 * @param mascircle [rate] magnetometer circle define rate data.
 * @param gyP [null] magnetometer Kalman filter P param.
 * @param gyQ [null] magnetometer Kalman filter Q param.
 * @param gyR [null] magnetometer Kalman filter R param.
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_magnetometer_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               uint32_t ma, uint32_t malvX, uint32_t mastartY, uint32_t malvY, uint32_t maAngle, uint32_t maNumber, uint32_t malingX, uint32_t malingY, uint32_t mascircle, uint32_t gyP, uint32_t gyQ, uint32_t gyR)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_Magnetometer_LEN];
    _mav_put_uint32_t(buf, 0, ma);
    _mav_put_uint32_t(buf, 4, malvX);
    _mav_put_uint32_t(buf, 8, mastartY);
    _mav_put_uint32_t(buf, 12, malvY);
    _mav_put_uint32_t(buf, 16, maAngle);
    _mav_put_uint32_t(buf, 20, maNumber);
    _mav_put_uint32_t(buf, 24, malingX);
    _mav_put_uint32_t(buf, 28, malingY);
    _mav_put_uint32_t(buf, 32, mascircle);
    _mav_put_uint32_t(buf, 36, gyP);
    _mav_put_uint32_t(buf, 40, gyQ);
    _mav_put_uint32_t(buf, 44, gyR);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_Magnetometer_LEN);
#else
    mavlink_magnetometer_t packet;
    packet.ma = ma;
    packet.malvX = malvX;
    packet.mastartY = mastartY;
    packet.malvY = malvY;
    packet.maAngle = maAngle;
    packet.maNumber = maNumber;
    packet.malingX = malingX;
    packet.malingY = malingY;
    packet.mascircle = mascircle;
    packet.gyP = gyP;
    packet.gyQ = gyQ;
    packet.gyR = gyR;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_Magnetometer_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_Magnetometer;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_Magnetometer_MIN_LEN, MAVLINK_MSG_ID_Magnetometer_LEN, MAVLINK_MSG_ID_Magnetometer_CRC);
}

/**
 * @brief Pack a magnetometer message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param ma [null] magnetometer X axis chip original data.
 * @param malvX [null] magnetometer X axis filtered data.
 * @param mastartY [null] magnetometer Y axis chip original data.
 * @param malvY [null] magnetometer Y axis filtered data.
 * @param maAngle [degree] magnetometer get angles data.
 * @param maNumber [num] magnetometer offset sample data number.
 * @param malingX [null] magnetometer X axis offset data.
 * @param malingY [null] magnetometer Y axis offset data.
 * @param mascircle [rate] magnetometer circle define rate data.
 * @param gyP [null] magnetometer Kalman filter P param.
 * @param gyQ [null] magnetometer Kalman filter Q param.
 * @param gyR [null] magnetometer Kalman filter R param.
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_magnetometer_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   uint32_t ma,uint32_t malvX,uint32_t mastartY,uint32_t malvY,uint32_t maAngle,uint32_t maNumber,uint32_t malingX,uint32_t malingY,uint32_t mascircle,uint32_t gyP,uint32_t gyQ,uint32_t gyR)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_Magnetometer_LEN];
    _mav_put_uint32_t(buf, 0, ma);
    _mav_put_uint32_t(buf, 4, malvX);
    _mav_put_uint32_t(buf, 8, mastartY);
    _mav_put_uint32_t(buf, 12, malvY);
    _mav_put_uint32_t(buf, 16, maAngle);
    _mav_put_uint32_t(buf, 20, maNumber);
    _mav_put_uint32_t(buf, 24, malingX);
    _mav_put_uint32_t(buf, 28, malingY);
    _mav_put_uint32_t(buf, 32, mascircle);
    _mav_put_uint32_t(buf, 36, gyP);
    _mav_put_uint32_t(buf, 40, gyQ);
    _mav_put_uint32_t(buf, 44, gyR);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_Magnetometer_LEN);
#else
    mavlink_magnetometer_t packet;
    packet.ma = ma;
    packet.malvX = malvX;
    packet.mastartY = mastartY;
    packet.malvY = malvY;
    packet.maAngle = maAngle;
    packet.maNumber = maNumber;
    packet.malingX = malingX;
    packet.malingY = malingY;
    packet.mascircle = mascircle;
    packet.gyP = gyP;
    packet.gyQ = gyQ;
    packet.gyR = gyR;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_Magnetometer_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_Magnetometer;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_Magnetometer_MIN_LEN, MAVLINK_MSG_ID_Magnetometer_LEN, MAVLINK_MSG_ID_Magnetometer_CRC);
}

/**
 * @brief Encode a magnetometer struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param magnetometer C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_magnetometer_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_magnetometer_t* magnetometer)
{
    return mavlink_msg_magnetometer_pack(system_id, component_id, msg, magnetometer->ma, magnetometer->malvX, magnetometer->mastartY, magnetometer->malvY, magnetometer->maAngle, magnetometer->maNumber, magnetometer->malingX, magnetometer->malingY, magnetometer->mascircle, magnetometer->gyP, magnetometer->gyQ, magnetometer->gyR);
}

/**
 * @brief Encode a magnetometer struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param magnetometer C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_magnetometer_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_magnetometer_t* magnetometer)
{
    return mavlink_msg_magnetometer_pack_chan(system_id, component_id, chan, msg, magnetometer->ma, magnetometer->malvX, magnetometer->mastartY, magnetometer->malvY, magnetometer->maAngle, magnetometer->maNumber, magnetometer->malingX, magnetometer->malingY, magnetometer->mascircle, magnetometer->gyP, magnetometer->gyQ, magnetometer->gyR);
}

/**
 * @brief Send a magnetometer message
 * @param chan MAVLink channel to send the message
 *
 * @param ma [null] magnetometer X axis chip original data.
 * @param malvX [null] magnetometer X axis filtered data.
 * @param mastartY [null] magnetometer Y axis chip original data.
 * @param malvY [null] magnetometer Y axis filtered data.
 * @param maAngle [degree] magnetometer get angles data.
 * @param maNumber [num] magnetometer offset sample data number.
 * @param malingX [null] magnetometer X axis offset data.
 * @param malingY [null] magnetometer Y axis offset data.
 * @param mascircle [rate] magnetometer circle define rate data.
 * @param gyP [null] magnetometer Kalman filter P param.
 * @param gyQ [null] magnetometer Kalman filter Q param.
 * @param gyR [null] magnetometer Kalman filter R param.
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_magnetometer_send(mavlink_channel_t chan, uint32_t ma, uint32_t malvX, uint32_t mastartY, uint32_t malvY, uint32_t maAngle, uint32_t maNumber, uint32_t malingX, uint32_t malingY, uint32_t mascircle, uint32_t gyP, uint32_t gyQ, uint32_t gyR)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_Magnetometer_LEN];
    _mav_put_uint32_t(buf, 0, ma);
    _mav_put_uint32_t(buf, 4, malvX);
    _mav_put_uint32_t(buf, 8, mastartY);
    _mav_put_uint32_t(buf, 12, malvY);
    _mav_put_uint32_t(buf, 16, maAngle);
    _mav_put_uint32_t(buf, 20, maNumber);
    _mav_put_uint32_t(buf, 24, malingX);
    _mav_put_uint32_t(buf, 28, malingY);
    _mav_put_uint32_t(buf, 32, mascircle);
    _mav_put_uint32_t(buf, 36, gyP);
    _mav_put_uint32_t(buf, 40, gyQ);
    _mav_put_uint32_t(buf, 44, gyR);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_Magnetometer, buf, MAVLINK_MSG_ID_Magnetometer_MIN_LEN, MAVLINK_MSG_ID_Magnetometer_LEN, MAVLINK_MSG_ID_Magnetometer_CRC);
#else
    mavlink_magnetometer_t packet;
    packet.ma = ma;
    packet.malvX = malvX;
    packet.mastartY = mastartY;
    packet.malvY = malvY;
    packet.maAngle = maAngle;
    packet.maNumber = maNumber;
    packet.malingX = malingX;
    packet.malingY = malingY;
    packet.mascircle = mascircle;
    packet.gyP = gyP;
    packet.gyQ = gyQ;
    packet.gyR = gyR;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_Magnetometer, (const char *)&packet, MAVLINK_MSG_ID_Magnetometer_MIN_LEN, MAVLINK_MSG_ID_Magnetometer_LEN, MAVLINK_MSG_ID_Magnetometer_CRC);
#endif
}

/**
 * @brief Send a magnetometer message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_magnetometer_send_struct(mavlink_channel_t chan, const mavlink_magnetometer_t* magnetometer)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_magnetometer_send(chan, magnetometer->ma, magnetometer->malvX, magnetometer->mastartY, magnetometer->malvY, magnetometer->maAngle, magnetometer->maNumber, magnetometer->malingX, magnetometer->malingY, magnetometer->mascircle, magnetometer->gyP, magnetometer->gyQ, magnetometer->gyR);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_Magnetometer, (const char *)magnetometer, MAVLINK_MSG_ID_Magnetometer_MIN_LEN, MAVLINK_MSG_ID_Magnetometer_LEN, MAVLINK_MSG_ID_Magnetometer_CRC);
#endif
}

#if MAVLINK_MSG_ID_Magnetometer_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This varient of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_magnetometer_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  uint32_t ma, uint32_t malvX, uint32_t mastartY, uint32_t malvY, uint32_t maAngle, uint32_t maNumber, uint32_t malingX, uint32_t malingY, uint32_t mascircle, uint32_t gyP, uint32_t gyQ, uint32_t gyR)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;
    _mav_put_uint32_t(buf, 0, ma);
    _mav_put_uint32_t(buf, 4, malvX);
    _mav_put_uint32_t(buf, 8, mastartY);
    _mav_put_uint32_t(buf, 12, malvY);
    _mav_put_uint32_t(buf, 16, maAngle);
    _mav_put_uint32_t(buf, 20, maNumber);
    _mav_put_uint32_t(buf, 24, malingX);
    _mav_put_uint32_t(buf, 28, malingY);
    _mav_put_uint32_t(buf, 32, mascircle);
    _mav_put_uint32_t(buf, 36, gyP);
    _mav_put_uint32_t(buf, 40, gyQ);
    _mav_put_uint32_t(buf, 44, gyR);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_Magnetometer, buf, MAVLINK_MSG_ID_Magnetometer_MIN_LEN, MAVLINK_MSG_ID_Magnetometer_LEN, MAVLINK_MSG_ID_Magnetometer_CRC);
#else
    mavlink_magnetometer_t *packet = (mavlink_magnetometer_t *)msgbuf;
    packet->ma = ma;
    packet->malvX = malvX;
    packet->mastartY = mastartY;
    packet->malvY = malvY;
    packet->maAngle = maAngle;
    packet->maNumber = maNumber;
    packet->malingX = malingX;
    packet->malingY = malingY;
    packet->mascircle = mascircle;
    packet->gyP = gyP;
    packet->gyQ = gyQ;
    packet->gyR = gyR;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_Magnetometer, (const char *)packet, MAVLINK_MSG_ID_Magnetometer_MIN_LEN, MAVLINK_MSG_ID_Magnetometer_LEN, MAVLINK_MSG_ID_Magnetometer_CRC);
#endif
}
#endif

#endif

// MESSAGE Magnetometer UNPACKING


/**
 * @brief Get field ma from magnetometer message
 *
 * @return [null] magnetometer X axis chip original data.
 */
static inline uint32_t mavlink_msg_magnetometer_get_ma(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  0);
}

/**
 * @brief Get field malvX from magnetometer message
 *
 * @return [null] magnetometer X axis filtered data.
 */
static inline uint32_t mavlink_msg_magnetometer_get_malvX(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  4);
}

/**
 * @brief Get field mastartY from magnetometer message
 *
 * @return [null] magnetometer Y axis chip original data.
 */
static inline uint32_t mavlink_msg_magnetometer_get_mastartY(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  8);
}

/**
 * @brief Get field malvY from magnetometer message
 *
 * @return [null] magnetometer Y axis filtered data.
 */
static inline uint32_t mavlink_msg_magnetometer_get_malvY(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  12);
}

/**
 * @brief Get field maAngle from magnetometer message
 *
 * @return [degree] magnetometer get angles data.
 */
static inline uint32_t mavlink_msg_magnetometer_get_maAngle(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  16);
}

/**
 * @brief Get field maNumber from magnetometer message
 *
 * @return [num] magnetometer offset sample data number.
 */
static inline uint32_t mavlink_msg_magnetometer_get_maNumber(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  20);
}

/**
 * @brief Get field malingX from magnetometer message
 *
 * @return [null] magnetometer X axis offset data.
 */
static inline uint32_t mavlink_msg_magnetometer_get_malingX(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  24);
}

/**
 * @brief Get field malingY from magnetometer message
 *
 * @return [null] magnetometer Y axis offset data.
 */
static inline uint32_t mavlink_msg_magnetometer_get_malingY(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  28);
}

/**
 * @brief Get field mascircle from magnetometer message
 *
 * @return [rate] magnetometer circle define rate data.
 */
static inline uint32_t mavlink_msg_magnetometer_get_mascircle(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  32);
}

/**
 * @brief Get field gyP from magnetometer message
 *
 * @return [null] magnetometer Kalman filter P param.
 */
static inline uint32_t mavlink_msg_magnetometer_get_gyP(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  36);
}

/**
 * @brief Get field gyQ from magnetometer message
 *
 * @return [null] magnetometer Kalman filter Q param.
 */
static inline uint32_t mavlink_msg_magnetometer_get_gyQ(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  40);
}

/**
 * @brief Get field gyR from magnetometer message
 *
 * @return [null] magnetometer Kalman filter R param.
 */
static inline uint32_t mavlink_msg_magnetometer_get_gyR(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  44);
}

/**
 * @brief Decode a magnetometer message into a struct
 *
 * @param msg The message to decode
 * @param magnetometer C-struct to decode the message contents into
 */
static inline void mavlink_msg_magnetometer_decode(const mavlink_message_t* msg, mavlink_magnetometer_t* magnetometer)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    magnetometer->ma = mavlink_msg_magnetometer_get_ma(msg);
    magnetometer->malvX = mavlink_msg_magnetometer_get_malvX(msg);
    magnetometer->mastartY = mavlink_msg_magnetometer_get_mastartY(msg);
    magnetometer->malvY = mavlink_msg_magnetometer_get_malvY(msg);
    magnetometer->maAngle = mavlink_msg_magnetometer_get_maAngle(msg);
    magnetometer->maNumber = mavlink_msg_magnetometer_get_maNumber(msg);
    magnetometer->malingX = mavlink_msg_magnetometer_get_malingX(msg);
    magnetometer->malingY = mavlink_msg_magnetometer_get_malingY(msg);
    magnetometer->mascircle = mavlink_msg_magnetometer_get_mascircle(msg);
    magnetometer->gyP = mavlink_msg_magnetometer_get_gyP(msg);
    magnetometer->gyQ = mavlink_msg_magnetometer_get_gyQ(msg);
    magnetometer->gyR = mavlink_msg_magnetometer_get_gyR(msg);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_Magnetometer_LEN? msg->len : MAVLINK_MSG_ID_Magnetometer_LEN;
        memset(magnetometer, 0, MAVLINK_MSG_ID_Magnetometer_LEN);
    memcpy(magnetometer, _MAV_PAYLOAD(msg), len);
#endif
}
